# _ * _ coding:utf-8 _ * _
import tornado.ioloop
import tornado.web
import tornado.httpserver, tornado.netutil, tornado.process
import os

# 谷歌在线编辑测试

class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r"/admin/?", "admin.index"),
            (r"/admin/(.+)/delete/", "admin.delete"),
            (r"/admin/(.+)/", "admin.edit"),
            (r"/?", "views.index"),
            (r"/(.*)/apply/?", "views.apply"),
            (r"/(.*)/result/?", "views.result"),
            (r"/(.*)", "views.view"),
        ]
        
        settings = dict(
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            ui_modules = {},
            xsrf_cookies = False,
            cookie_secret = "4169be66c09789e7cc112853a744b18a",
            # autoescape = xhtml_escape,
            debug = True,
        )
        
        tornado.web.Application.__init__(self, handlers, **settings)
        
"""
def git_pull():
    os.system("git pull")
"""
    
if __name__ == "__main__":
    
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.bind(8080)
    http_server.start(1)
    # tornado.ioloop.PeriodicCallback(git_pull, 10000).start()
    # application.listen(8080)
    tornado.ioloop.IOLoop.instance().start()

